/*
 * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.love.cloud.admin.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.love.cloud.admin.api.dto.UserDTO;
import com.love.cloud.admin.api.dto.UserInfo;
import com.love.cloud.admin.api.entity.SysUser;
import com.love.cloud.admin.api.vo.*;

import java.util.List;
import java.util.Map;

/**
 * @author lengleng
 * @date 2019/2/1
 */
public interface SysUserService extends IService<SysUser> {

	/**
	 * 查询用户信息
	 * @param sysUser 用户
	 * @return userInfo
	 */
	UserInfo getUserInfo(SysUser sysUser);

	/**
	 * 分页查询用户信息（含有角色信息）
	 * @param page 分页对象
	 * @param userDTO 参数列表
	 * @return
	 */
	IPage getUserWithRolePage(Page page, UserDTO userDTO);

	/**
	 * 删除用户
	 * @param sysUser 用户
	 * @return boolean
	 */
	Boolean removeUserById(SysUser sysUser);

	/**
	 * 更新当前用户基本信息
	 * @param userDto 用户信息
	 * @return Boolean 操作成功返回true,操作失败返回false
	 */
	Boolean updateUserInfo(UserDTO userDto);
	/**
	 * 修改密码
	 * @param userDto 用户信息
	 * @return Boolean 操作成功返回true,操作失败返回false
	 */
	Boolean changePassword(UserDTO userDto);

	/**
	 * 重置密码
	 * @param userDto
	 * @return
	 */
	Boolean resetPassword(UserDTO userDto);

	/**
	 * 获取到忘记密码的验证码
	 * @param forgetPasswordVo
	 * @return
	 */
	Object getForgetPasswordValidCode(ForgetPasswordVo forgetPasswordVo);

	/**
	 * 忘记密码-校验验证码
	 * @param forgetPasswordVo
	 * @return
	 */
	Object checkForgetPasswordValidCode(ForgetPasswordVo forgetPasswordVo);

	/**
	 * 忘记密码-设置新的密码
	 * @param forgetPasswordVo
	 * @return
	 */
	Object forgetPasswordSetNewPassword(ForgetPasswordVo forgetPasswordVo);

	/**
	 * 绑定手机号
	 * @param
	 * @return Boolean 操作成功返回true,操作失败返回false
	 */
	Boolean bindMobile(ForgetPasswordVo forgetPasswordVo);

	/**
	 * 获取到手机号
	 */
	String getMobile();

	/**
	 * 更新指定用户信息
	 * @param userDto 用户信息
	 * @return
	 */
	Boolean updateUser(UserDTO userDto);

	/**
	 * 通过ID查询用户信息
	 * @param id 用户ID
	 * @return 用户信息
	 */
	UserVO getUserVoById(Long id);


	/**
	 * 保存用户信息
	 * @param userDto DTO 对象
	 * @return success/fail
	 */
	SysUser saveUser(UserDTO userDto);

	/**
	 * 获取到保存用户数据
	 * @param userDto
	 * @return
	 */
	SysUser getSaveUser(UserDTO userDto);

	/**
	 * 更新用户状态
	 * @return
	 */
	Object updateUserStatus(UpdateUserVo updateUserVo);

	/**
	 * 获取到部门用户信息
	 * @param deptUsersVo
	 * @return
	 */
	Object getDeptUsers(DeptUsersVo deptUsersVo);

	/**
	 * 获取到选人组件的数据
	 * @param selectDataVo
	 * @return
	 */
	Object getSelectData(SelectDataVo selectDataVo);

	/**
	 * 过滤查询
	 *
	 * @param params type 类型；name 查询条件
	 * @return
	 */
	Object filterTreeData(Map<String, Object> params);

	/**
	 * 通过部门id获取到用户列表
	 * @return
	 */
	List<UserVO> getUserListDeptId(Long deptId);

	/**
	 * 通过部门id获取到部门下面的用户列表
	 *
	 * @param deptId
	 * @param position
	 * @return
	 */
	List<SysUser> getUserListDeptId(String deptId, String position);

	List<UserVO> getRoleUsers(Long roleId);

	/**
	 * 清除缓存
	 */
	void clearUserDetailCache(SysUser sysUser);

	/**
	 * 清除对应用户的全部token信息
	 * @return
	 */
	void clearUserToken(SysUser sysUser);

	boolean updateOpenCodeByUserId(Long userId, String openCode);

	/**
	 * 绑定手机号获取验证码
	 * @param forgetPasswordVo
	 * @return
	 */
    Object getValidCode(ForgetPasswordVo forgetPasswordVo);
}
